﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Text;
using OgilvyOne.BLL;

/// <summary>
/// 会员中心基类
/// </summary>
public class MemberBasePage : FrontBasePage
{
    protected override void OnLoad(EventArgs e)
    {
        Response.Expires = -1;
        Response.AddHeader("Pragma", "no-cache");
        Response.AddHeader("Cache-Control", "no-cache");

        if ( GetSessionMemberInfo() == null)
        {
            Response.Redirect("/cn/member/login.aspx", true);
            return;
        }
        base.OnLoad(e);
    }
    public MemberBasePage()
    {
        
    }
    public const string UIMG = "/imageedit/UploadFiles/Small/";
    public string GetLeftMainMenuHtml(int navi)
    {
        StringBuilder sb = new StringBuilder();
        sb.Append("<div class=\"mainMenu\">\n");
        string userimg = "/cn/images/titleuser.gif";
        sb.Append("<h2><a href=\"index.aspx\"><img src=\"" + userimg + "\" border=\"0\"/></a></h2>\n");
        sb.Append("<div class=\"menuInfo\">\n");
        string uimg = "/cn/images/w_userLeftPic.jpg";
        if (GetSessionMemberInfo().Userimg != null && GetSessionMemberInfo().Userimg != "")
        {
            uimg = "/imageedit/UploadFiles/Small/" + GetSessionMemberInfo().Userimg;
        }
        sb.Append("<div class=\"menuBanner\"><img src=\"" + uimg + "\" width=\"166\"/></div>\n");
        sb.Append("<dl>\n");
        sb.Append("<dt" + (navi == 7 ? " class=\"current\"" : "") + "><a href=\"index.aspx\" class=\"menuIDT\">会员中心</a></dt>\n");
        sb.Append("</dl>\n");
        sb.Append("<dl>\n");
        sb.Append("<dt" + (navi == 1 ? " class=\"current\"" : "") + "><a href=\"activity.aspx\" class=\"menuIDT\">推荐活动</a></dt>\n");
        sb.Append("</dl>\n");
        sb.Append("<dl>\n");
        sb.Append("<dt" + (navi == 8 ? " class=\"current\"" : "") + "><a href=\"womaiactivitylist.aspx\" class=\"menuIDT\">我买特惠</a></dt>\n");
        sb.Append("</dl>\n");
        sb.Append("<dl>\n");
        sb.Append("<dt" + (navi == 2 ? " class=\"current\"" : "") + "><a href=\"colls.aspx\" class=\"menuIDT\">我的收藏</a></dt>\n");
        sb.Append("</dl>\n");
        sb.Append("<dl>\n");
        sb.Append("<dt" + (navi == 3 ? " class=\"current\"" : "") + "><a href=\"messages.aspx\" class=\"menuIDT\">我的留言</a></dt>\n");
        sb.Append("</dl>\n");
        sb.Append("<dl>\n");
        sb.Append("<dt" + (navi == 4 ? " class=\"current\"" : "") + "><a href=\"activitytitbits.aspx\" class=\"menuIDT\">我的活动花絮</a></dt>\n");
        sb.Append("</dl>\n");
        if (GetSessionMemberInfo().UserType == MemberInfoBll.MEMBER_TYPE_COFCO)
        {
            sb.Append("<dl" + (navi == 5 || navi == 6 ? " class=\"current\"" : "") + ">\n");
            sb.Append("<dt><a href=\"javascript:;\" class=\"menuID2\">我的资料</a></dt>\n");
            sb.Append("<dd" + (navi == 5 ? " class=\"current\"" : "") + "><a href=\"person_document.aspx\" class=\"menuIDD\">基本资料</a></dd>\n");
            sb.Append("<dd" + (navi == 6 ? " class=\"current\"" : "") + "><a href=\"pass.aspx\" class=\"menuIDD\">修改密码</a></dd>\n");
            sb.Append("</dl>\n");
        }
        sb.Append("</div>\n");
        sb.Append("</div>\n");
        return sb.ToString();
    }

    protected override int GetColumnId()
    {
        return ConConstants.MEMBER_CID;
    }

    public override string GetMeta()
    {
        return "<title>会员中心 - " + ConConstants.WEB_NAME + "</title>";
    }

    public string GetPositionNavi()
    {
        return "<div class=\"manNavBar\">\n" 
              +"      您的位置 &nbsp; <a href=\"/cn/index.html\">首页</a> | <span>会员中心</span>\n"
              +"  </div>";
    }
    public int GetPageStartNo(int pagein, int num)
    {
        int inint = 1;
        if (num > 5 && pagein > 3)
        {
            if (pagein < num - 1)
            {
                inint = pagein - 2;
            }
            else
            {
                inint = num - 4;
            }
        }
        return inint;
    }
}
